package dp.路径;

import java.util.ArrayList;
import java.util.List;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 杨辉三角ii119.java
 * @Description https://leetcode-cn.com/problems/pascals-triangle-ii/
 * @createTime 2021年11月09日 20:39:00
 */
public class 杨辉三角ii119 {

	public static List<Integer> getRow(int rowIndex) {
		List<Integer> result = new ArrayList<>();
		int[][] dp = new int[rowIndex+1][rowIndex+1];
		dp[0][0] = 1;

		for (int i = 1; i <= rowIndex; i++) {
			for (int j = 0; j <= i; j++) {
				if (j == 0) {
					dp[i][j] = 1;
				} else {
					dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
				}
			}
		}

		int[] res = dp[rowIndex];
		for (int re : res) {
			result.add(re);
		}
		return result;
	}

	public static void main(String[] args) {
		getRow(3);
	}
}
